/*    */ package cc.s2m.web.s2mBlog.util;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import java.sql.Connection;
/*    */ import java.sql.SQLException;
/*    */ import java.util.Map;
/*    */ import java.util.concurrent.ExecutorService;
/*    */ import java.util.concurrent.Executors;
/*    */ import javax.servlet.ServletContext;
/*    */ import javax.sql.DataSource;
/*    */ import javax.xml.parsers.DocumentBuilder;
/*    */ import javax.xml.parsers.DocumentBuilderFactory;
/*    */ import javax.xml.parsers.ParserConfigurationException;
/*    */ import main.java.com.UpYun;
/*    */ import org.apache.logging.log4j.LogManager;
/*    */ import org.apache.logging.log4j.Logger;
/*    */ import org.springframework.core.io.ClassPathResource;
/*    */ import org.springframework.core.io.Resource;
/*    */ import org.springframework.jdbc.datasource.DriverManagerDataSource;
/*    */ import org.w3c.dom.Document;
/*    */ import org.w3c.dom.Element;
/*    */ import org.w3c.dom.Node;
/*    */ import org.w3c.dom.NodeList;
/*    */ import org.xml.sax.SAXException;
/*    */ 
/*    */ public class StaticProp
/*    */ {
/*    */   public static Map<Object, Object> sysConfig;
/*    */   private static DataSource dataSource;
/* 32 */   public static final Logger SYSTEM = LogManager.getLogger("SYSLOG");
/*    */   public static ServletContext servletContext;
/* 35 */   public static ExecutorService execute = Executors.newFixedThreadPool(20);
/*    */ 
/* 37 */   public static String[] allowFiles = { ".rar", ".doc", ".docx", ".zip", ".pdf", ".txt", ".swf", ".wmv", ".gif", ".png", ".jpg", ".jpeg", ".bmp" };
/*    */   public static UpYun upyun;
/*    */   public static String upYunPath;
/* 42 */   public static String cookieID = "s2mBlog";
/* 43 */   public static String WX_TOKEN = "";
/*    */ 
/*    */   public static Connection getDatabaseConnection() throws SQLException, SAXException, IOException, ParserConfigurationException
/*    */   {
/* 47 */     if (dataSource == null) {
/* 48 */       Resource resource = new ClassPathResource("spring-core.xml");
/* 49 */       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
/* 50 */       DocumentBuilder db = dbf.newDocumentBuilder();
/* 51 */       Document doc = db.parse(resource.getInputStream());
/* 52 */       NodeList beanList = doc.getElementsByTagName("bean");
/* 53 */       DriverManagerDataSource ds = new DriverManagerDataSource();
/* 54 */       ds.setDriverClassName("com.mysql.jdbc.Driver");
/* 55 */       for (int i = 0; i < beanList.getLength(); i++)
/*    */       {
/* 57 */         Node bean = beanList.item(i);
/* 58 */         Element elem = (Element)bean;
/* 59 */         if (elem.getAttribute("name").equals("dataSource"))
/*    */         {
/* 62 */           NodeList propertys = elem.getElementsByTagName("property");
/* 63 */           for (int j = 0; j < propertys.getLength(); j++) {
/* 64 */             Node propertysNode = propertys.item(j);
/* 65 */             Element propertysElement = (Element)propertysNode;
/* 66 */             if (propertysElement.getAttribute("name").equals("url")) {
/* 67 */               ds.setUrl(propertysElement.getAttribute("value"));
/*    */             }
/* 69 */             if (propertysElement.getAttribute("name").equals("username")) {
/* 70 */               ds.setUsername(propertysElement.getAttribute("value"));
/*    */             }
/* 72 */             if (propertysElement.getAttribute("name").equals("password"))
/* 73 */               ds.setPassword(propertysElement.getAttribute("value"));
/*    */           }
/*    */         }
/*    */       }
/* 77 */       dataSource = ds;
/*    */     }
/* 79 */     return dataSource.getConnection();
/*    */   }
/*    */ 
/*    */   public static String getSysConfigString(String key) {
/* 83 */     return (String)sysConfig.get(key);
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.util.StaticProp
 * JD-Core Version:    0.6.1
 */